/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RegistroDeposito.java
 *
 * Created on 27-feb-2012, 1:53:38
 */
package view;

import entity.Empleado;
import entity.Movimiento;
import javax.swing.JOptionPane;
import service.EurekaService;
import util.Memoria;

/**
 *
 * @author AnDerSon
 */
public class RegistroDeposito extends javax.swing.JInternalFrame {

    Empleado obj;
    
    	private static RegistroDeposito instancia = null;
	
	static {
		instancia = new RegistroDeposito();
	}

	public static RegistroDeposito getInstancia() {
		return instancia;
	}
    
    
    
    /** Creates new form RegistroDeposito */
    public RegistroDeposito() {
        initComponents();
        obj = (Empleado) Memoria.get("empleado");
        this.txtCodEmpleado.setText(obj.getCodigo()+" ");
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        txtNumCuenta = new javax.swing.JTextField();
        txtImport = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        btnConDeposito = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        txtCodEmpleado = new javax.swing.JTextField();

        setClosable(true);
        setTitle("Eureka Bank");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24));
        jLabel1.setForeground(new java.awt.Color(0, 153, 255));
        jLabel1.setText("Registrar Deposito");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 10, -1, -1));
        getContentPane().add(txtNumCuenta, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 170, 230, -1));
        getContentPane().add(txtImport, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 240, 70, -1));

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(0, 102, 255));
        jLabel2.setText("Numero Cuenta");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 140, -1, -1));

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel3.setForeground(new java.awt.Color(0, 102, 255));
        jLabel3.setText("Importe a Depositar");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 210, -1, -1));

        btnConDeposito.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnConDeposito.setForeground(new java.awt.Color(0, 102, 255));
        btnConDeposito.setText("Generar Deposito");
        btnConDeposito.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConDepositoActionPerformed(evt);
            }
        });
        getContentPane().add(btnConDeposito, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 270, -1, 50));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(0, 102, 255));
        jLabel4.setText("Codigo del Empleado");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 70, -1, -1));

        txtCodEmpleado.setEditable(false);
        getContentPane().add(txtCodEmpleado, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 100, 130, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnConDepositoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConDepositoActionPerformed
// TODO add your handling code here:
    
    Movimiento m = new Movimiento();
    m.setCuenta(txtNumCuenta.getText());
    m.setImporte(txtImport.getText());
    m.setEmpleado(txtCodEmpleado.getText().trim());
    
    EurekaService es = new EurekaService();
    String msj = es.registrarDeposito(m);
    
    
    if (msj.equals("ok")) {
        
        JOptionPane.showMessageDialog(this, "Tarea Realizada con Exito");
    } else{
        JOptionPane.showMessageDialog(this, "Tarea no se Realizada con Exito");
    }

    
    
}//GEN-LAST:event_btnConDepositoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConDeposito;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JTextField txtCodEmpleado;
    private javax.swing.JTextField txtImport;
    private javax.swing.JTextField txtNumCuenta;
    // End of variables declaration//GEN-END:variables
}
